home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-23 | 4.0 KB | 157 lines | [TEXT/EDIT] |
- // This may look like C code, but it is really -*- C++ -*-
- /*
- Copyright (C) 1988, 1992 Free Software Foundation
- written by Doug Lea (dl@rocky.oswego.edu)
-
- This file is part of the GNU C++ Library. This library is free
- software; you can redistribute it and/or modify it under the terms of
- the GNU Library General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your
- option) any later version. This library is distributed in the hope
- that it will be useful, but WITHOUT ANY WARRANTY; without even the
- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the GNU Library General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-
- #pragma once
- #ifndef _std_h
- #define _std_h 1
-
- #include <stddef.h>
-
- #if 0
- typedef unsigned size_t;
- #endif
-
- typedef char wchar_t;
-
- #ifndef NULL
- #ifdef __cplusplus
- #define NULL 0
- #else
- #define NULL ((void *) 0)
- #endif
- #endif
-
- inline int abs(const int x) { return x >= 0 ? x : -x; }
-
- //------------------------------------------------------------------------
- // The following is rolled-out <stdlib.h>
- //
-
-
- extern "C" {
-
- typedef struct { int quot, rem; } div_t;
- typedef struct { long quot, rem; } ldiv_t;
-
- int atoi(const char *);
- long atol(const char *);
- double strtod(const char *, char **);
- long strtol(const char *, char **, int);
- unsigned long strtoul(const char *, char **, int);
-
- int rand(void);
- void srand(unsigned);
-
- void *calloc(size_t, size_t);
- void free(void *);
- void *malloc(size_t);
- void *realloc(void *, size_t);
-
- void abort(void);
- int atexit(void (*)(void));
- void exit(int);
- char *getenv(const char *);
- int system(const char *);
-
- typedef int (*__cmp_func)(const void *, const void *);
- void *bsearch(const void *, const void *, size_t, size_t, __cmp_func);
- void qsort(void *, size_t, size_t, void *);
-
- //int abs(int);
- div_t div(int, int);
- long labs(long);
- ldiv_t ldiv(long, long);
-
- int mblen(const char *, size_t);
- int mbtowc(wchar_t *, const char *, size_t);
- int wctomb(char *, wchar_t);
-
- size_t mbstowcs(wchar_t *, const char *, size_t);
- size_t wcstombs(char *, const wchar_t *, size_t);
-
- typedef void (*__exit_func)(void);
- void _exit(int);
- int _atexit(__exit_func);
- void _exiting(int);
- extern int _abnormal_exit;
-
- typedef int (*__cmp1_func)(size_t, size_t);
- typedef void (*__swap1_func)(size_t, size_t);
- void _qsort(size_t, __cmp1_func, __swap1_func);
-
- }
-
-
- //------------------------------------------------------------------------
- // The following is rolled-out <string.h>
- //
- extern "C" {
-
- void *memcpy(void *, const void *, size_t);
- void *memmove(void *, const void *, size_t);
- char *strcpy(char *, const char *);
- char *strncpy(char *, const char *, size_t);
-
- char *strcat(char *, const char *);
- char *strncat(char *, const char *, size_t);
-
- int memcmp(const void *, const void *, size_t);
- int strcmp(const char *, const char *);
- int strcoll(const char *, const char *);
- int strncmp(const char *, const char *, size_t);
- size_t strxfrm(char *, const char *, size_t);
-
- void *memchr(const void *, int, size_t);
- char *strchr(const char *, int);
- size_t strcspn(const char *, const char *);
- char *strpbrk(const char *, const char *);
- char *strrchr(const char *, int);
- size_t strspn(const char *, const char *);
- char *strstr(const char *, const char *);
- char *strtok(char *, const char *);
-
- void *memset(void *, int, size_t);
- char *strerror(int);
- size_t strlen(const char *);
- int sprintf(char *, const char *, ...);
- int sscanf(const char *, const char *, ...);
- }
-
- inline char * strdup(const char * str) { return strcpy((char *)malloc(strlen(str)+1),str); }
-
-
- //------------------------------------------------------------------------
- // The following is rolled-out <memory.h>
- //
-
-
-
- //------------------------------------------------------------------------
- // The following is rolled-out <errno.h>
-
- #include <errno.h>
-
-
- //#include <unistd.h>
- //#include <stdio.h>
- //#include <fcntl.h>
-
- #endif
-
-